<template>
	<view>
		<view class="uni-tab-bar">
			<scroll-view class="uni-swiper-tab" scroll-x="true">
				<block v-for="(tab,index) in tabBars" :key="tab.id" :style="scrollStyle">
					<view class="swiper-tab-list" :class="{'active' :tabIndex==index}" @tap="tabtap(index)"
						:style="scrollItemStyle">
						{{tab.name}} {{tab.num?tab.num:""}}
						<view class="swiper-tab-line"></view>
					</view>
				</block>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "wode-jisuan",
		props: {
			tabBars: Array,
			tabIndex: Number,
			scrollStyle: {
				type: String,
				default: ""
			},
			scrollItemStyle: {
				type: String,
				default: ""
			}
		},
		methods: {
			tabtap(index) {
				//点击tab时把自己的index传给父组件index.vue
				this.$emit('tabtap', index);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.uni-swiper-tab {
		display: flex;
		white-space: nowrap;
		width: 90%;
		margin: auto;
		height: 73rpx !important;
		line-height: 63rpx;
	}

	.swiper-tab-list {
		width: 172rpx;
		display: inline-block;
		white-space: nowrap;
		text-align: center;
		color: #B9B9B9;
		margin-left: 35rpx;
	}

	.uni-tab-bar .active {
		color: #0E5642;
		text-align: center;
	}

	.active .swiper-tab-line {
		text-align: center;
		border-bottom: 3rpx solid #0E5642;
		width: 140rpx;
		margin: auto;
		border-radius: 20rpx;
	}
</style>
